﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Users;
using System.Threading;
using Sim;
namespace Sim
{
    public partial class SignUp : Form, ISignUp
    {
        public SignUp()
        {
            InitializeComponent();
        }

        private void SignUp_Load()
        {
            this.comboBoxSignUpGender.SelectedIndex = 0;
            this.comboBoxSignUpRole.SelectedIndex = 0;
        }


        private void buttonSignUp_Click(object sender, EventArgs e)
        {
            if (EventSignUp != null)
            {               
                User u = new User();
                u.firstName = textBoxFirstName.Text;
                u.lastName = textBoxLastName.Text;
                try
                {
                    u.age = Convert.ToInt32(textBoxAge.Text);
                }
                catch (Exception ex)
                {
                    textBoxAge.BackColor = Color.Salmon;
                    return;
                }
                u.nation = textBoxNation.Text;
                u.sex = comboBoxSignUpGender.Text;
                u.level = comboBoxSignUpRole.SelectedIndex;
                u.username = textBoxUsername.Text;
                u.password = textBoxPassword.Text;
                EventSignUp(u);
                Thread.Sleep(100);
                if (Program.flagg == true)
                {
                    Program.flagg = false;
                    MessageBox.Show("Success!");
                    Close();
                }
                else
                {
                    MessageBox.Show("FUCK YOU");
                }
                    
            }
        }

        public event DelegateSignUp EventSignUp = null;

       
        
    }
}
